<script setup>
import {defineEmits, onMounted, reactive} from "vue";
import {getSystemByCode} from "@/api/basal.js";
import {ResultEnums} from "@/enums/ResultStatusEnums.js";
const emit = defineEmits(['innerLink'])
const system = reactive({systemIcon:'',systemName:'名字在嘴边'})
onMounted(() => {
  getSystemByCode(import.meta.env.VITE_SYSTEM_CODE).then(result => {
    if (result.code === ResultEnums.SUCCESS) {
      const data = result.data
      for(const key in data){
        system[key] = data[key]
      }
    }else {
      system.systemIcon = ''
      system.systemName = '名字在嘴边'
    }
  })
})

function innerLink(e,url,params){
  e.preventDefault();
  emit('innerLink',url,params)
}

</script>

<template>
  <div class="app-branding">
    <a class="app-logo" href="#" @click="innerLink($event,'/home/index',{})">
      <template v-if="system.systemIcon">
        <img class="logo-icon me-2" :src="system.systemIcon" alt="logo">
      </template>
      <template v-else>
        <img class="logo-icon me-2" src="../../assets/images/app-logo.svg" alt="logo">
      </template>
      <span class="logo-text">{{ system.systemName }}</span>
    </a>
  </div>
</template>

<style scoped>

</style>